import React, { ReactElement , useEffect} from 'react'
import { UserOutlined, LaptopOutlined, NotificationOutlined } from '@ant-design/icons';
import { Switch, Route, Redirect, Link } from "react-router-dom";
import { Layout, Menu, Breadcrumb, Popconfirm, message } from 'antd';

const { SubMenu } = Menu;

interface Props {
    flag:boolean,
}

export default function Menus({flag}: Props): ReactElement {

    //刷新页面后保持打开上次选中的导航的父级导航
    // const openKey = () => {
    //     let pathname = this.props.pathname
    //     if (pathname.includes("datav")) {
    //         return "/home/datav"
    //     } else if (pathname.includes("product")) {
    //         return "/home/product"
    //     } else {
    //         return pathname
    //     }
    // }
    return (
        <>
        <Menu
            mode="inline"
            // 刷新页面后保持选中上次选中的导航
            // defaultSelectedKeys={[this.props.pathname]}
            // defaultOpenKeys={[this.openKey()]}
            style={{ height: '100%', borderRight: 0 ,backgroundColor:"#001529",color:"#a6adb4"}}
        >

            {/* {this.initMenu(menuConfig)} */}
            <Menu.Item key="/home" icon={<UserOutlined></UserOutlined>}>
                <Link to="/home">系统主页</Link>
            </Menu.Item>
            <SubMenu key="homo/system" icon={<NotificationOutlined />} title="系统管理">
                <Menu.Item key="/home/system/user"><Link to="/home/system/user">用户管理</Link></Menu.Item>
                <Menu.Item key="/home/system/role"><Link to="/home/system/role">角色管理</Link></Menu.Item>
                <Menu.Item key="/home/system/menus"><Link to="/home/system/menus">菜单管理</Link></Menu.Item>
                <Menu.Item key="/home/system/dist"><Link to="/home/system/dist">字典管理</Link></Menu.Item>
            </SubMenu>
            <SubMenu key="/home/monitor" icon={<LaptopOutlined />} title="系统监控">
                <Menu.Item key="/home/monitor/online"><Link to="/home/monitor/online">在线用户</Link></Menu.Item>
                <Menu.Item key="/home/monitor/systemlog"><Link to="/home/monitor/systemlog">系统日志</Link></Menu.Item>
            </SubMenu>
            <SubMenu key="/home/gen" icon={<LaptopOutlined />} title="商铺管理">
                <Menu.Item key="/home/gen/charge"><Link to="/home/gen/charge">电站审核</Link></Menu.Item>
                <Menu.Item key="/home/gen/apply"><Link to="/home/gen/apply">商铺审核</Link></Menu.Item>
                <Menu.Item key="/home/gen/complain"><Link to="/home/gen/complain">投诉管理</Link></Menu.Item>
                <Menu.Item key="/home/gen/shop"><Link to="/home/gen/shop">门店管理</Link></Menu.Item>
            </SubMenu>
            <SubMenu key="/home/serve" icon={<LaptopOutlined />} title="服务项目">
                <Menu.Item key="/home/serve/category"><Link to="/home/serve/category">类别管理</Link></Menu.Item>
            </SubMenu>
            <SubMenu key="/home/goods" icon={<LaptopOutlined />} title="商品管理">
                <Menu.Item key="/home/goods/goodsType"><Link to="/home/goods/goodsType">商品类别管理</Link></Menu.Item>
            </SubMenu>
        </Menu>
    </>
    )
}
